/** 铁匠铺 */
var updatearea = require("./updatearea"), combobox = require("../base/combobox.js");
cc.Class({
    extends: cc.Component,

    properties: {
        /** 升级对象 */
        upObj:updatearea,
        /** 英雄列表 */
        cb_herolist:combobox,
        /** 购买元素 */
        pf_item:cc.Prefab,
        /** 显示元素 */
        nd_item:cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.nd_item.removeAllChildren();

        let bd = App.U.city[App.cid].area[2];
        if(bd.refresh - Date.now() - App.dtm > 2*3600*1000){
            App.net.send(2,48,{cid:App.cid});
        }else{
            this.upItem();
        }
    },
    /** 更新装备 */
    upItem(){

    },
    /** 接受到网络消息 */
    onNetData(msg){
        cc.log("forger", msg[1]);
        if(msg[1] == 148 || msg[1] == 149){ //刷新
            let bd = App.U.city[App.cid].area[2];
            bd.refresh = Date.now();
            bd.gem = msg[2].gem;
            this.upItem();
        }else if(msg[1] == 150){ //购买装备
            let bd = App.U.city[App.cid].area[2];
            bd.gem.splice(bd.gem.indexOf(msg[2].gid), 1);
            App.U.res.coin -= App.C.gem[msg[2].gid][2]*2;
            this.upItem();
        }
    },
    // update (dt) {},
});
